package com.zhny.project.exec.outcome.service.impl;

import java.util.List;
import java.util.UUID;

import com.zhny.common.utils.DateUtils;
import com.zhny.project.exec.algorithm.domain.ExecAlgorithm;
import com.zhny.project.exec.algorithm.mapper.ExecAlgorithmMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhny.project.exec.outcome.service.IOutcomeService;
import com.zhny.common.utils.text.Convert;

/**
 * 算法执行结果Service业务层处理
 * 
 * @author lxh
 * @date 2019-10-17
 */
@Service
public class OutcomeServiceImpl implements IOutcomeService 
{

    @Autowired
    private ExecAlgorithmMapper execAlgorithmMapper;

    /**
     * 查询算法执行结果
     * 
     * @param exceKey 算法执行结果ID
     * @return 算法执行结果
     */
    @Override
    public ExecAlgorithm selectOutcomeById(String exceKey)
    {
        return execAlgorithmMapper.selectExecAlgorithmById(exceKey);
    }

    /**
     * 查询算法执行结果列表
     * 
     * @param outcome 算法执行结果
     * @return 算法执行结果
     */
    @Override
    public List<ExecAlgorithm> selectOutcomeList(ExecAlgorithm outcome)
    {
        return execAlgorithmMapper.selectExecAlgorithmList(outcome);
    }

    /**
     * 新增算法执行结果
     * 
     * @param outcome 算法执行结果
     * @return 结果
     */
    @Override
    public int insertOutcome(ExecAlgorithm execAlgorithm)
    {
        execAlgorithm.setExceKey(UUID.randomUUID().toString());
        execAlgorithm.setCreateTime(DateUtils.getNowDate());
        return execAlgorithmMapper.insertExecAlgorithm(execAlgorithm);
    }

    /**
     * 修改算法执行结果
     * 
     * @param outcome 算法执行结果
     * @return 结果
     */
    @Override
    public int updateOutcome(ExecAlgorithm execAlgorithm)
    {
        execAlgorithm.setUpdateTime(DateUtils.getNowDate());
        return execAlgorithmMapper.updateExecAlgorithm(execAlgorithm);
    }

    /**
     * 删除算法执行结果对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteOutcomeByIds(String ids)
    {
        return execAlgorithmMapper.deleteExecAlgorithmByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除算法执行结果信息
     * 
     * @param exceKey 算法执行结果ID
     * @return 结果
     */
    public int deleteOutcomeById(String exceKey)
    {
        return execAlgorithmMapper.deleteExecAlgorithmById(exceKey);
    }
}
